This page last changed on Oct 25, 2006 by andrew.

This is a standard Jms 1.0.2b and 1.1 connector. This connector exposes all features defined in the 1.0.2b/1.1 Specification.

The javadoc for this transport provider can be found here. And the Source Xref can be found here.

Property Description Default Required
acknowledgementMode Determine the type of acknowledegement made when a message is received. The Jms Specification identifies 4 possible values -
Session.TRANSACTED (0) The acknowledgement mode is ingored by the session. This constant was introduced in Jms 1.1 but the value is valid in Jms 1.0.2b.
Session.AUTO_ACKNOWLEDGE (1) - the session automatically acknowledges a client's receipt of a message either when the session has successfully returned from a call to receive or when the message listener on the session has called to process the message successfully returns.
Session.CLIENT_ACKNOWLEDGE (2) - the client acknowledges a consumed message by calling the message's acknowledge method.
Session.DUPS_OK (3) - instructs the session to lazily acknowledge the delivery of messages.
1 Yes
persistentDelivery Determines whether the underlying JMS provider will store a message to a persistent storage as part of the send operation. There is a performance overhead in persisting messages, so it should only be used in situations where the receiving application will have problems if the message is not delivered. Setting this value to true will enable persistent delivery, false to disable it. false Yes
specification The jms specification supported by your jms server. This can either be 1.0.2b or 1.1 1.0.2b Yes
durable If a client needs to receive all the messages published on a topic, including the ones published while the subscriber is inactive, it uses a durable TopicSubscriber. The JMS provider retains a record of this durable subscription and insures that all messages from the topic's publishers are retained until they are acknowledged by this durable subscriber or they have expired. Setting this value to true will ensure that all topic subscribers that use this connector will be durable (unless durable properties are overriden on the endpoint. See below) false Yes
clientId Used to uniquely identify the client for this connection. It must be set when using durable subscribers. Often the jms provider will set this, but for some jms servers you may need to set this yourself. If the value you set is not unique to the Jms Server a javax.jms.InvalidClientIDException is thrown.   yes (if using durable)
noLocal The subscriber noLocal attribute allows a subscriber to inhibit the delivery of messages published by its own connection. false No
jndiInitialFactory Defines the initial context factory to use when retriving objects, such as JmsConnectionFactory from your JNDI context. If you set the connectionFactory   Yes
jndiProviderUrl Your JNDI provider url.   Yes (if using jndi)
jndiProviderProperties Any other properties to pass to the initial context. Properties such as java.naming.username and java.naming.password can be set here.   No
connectionFactoryProperties Any properties to be passed to the javax.jms.ConnectionFactory, e.g. to set some vendor-specific properties.   No
connectionFactoryJndiName The name of the JNDI configured connection factory to use.   Yes (if using jndi)
connectionFactory The Jms connection factory to use. This can be set on the connector directly so that Jndi properties are not needed.   No (if using jndi)
connectionFactoryClass  Native connection factory class name (e.g. for standalone WebSphere MQ, Sun Message Queue), when no JNDI or IoC container is being used.  @since 1.3
  No 
jndiDestinations Determines if jndi destinations are being used. this will casue jms queues and topics to be loaded from the jndi context. If the destination is not found a default non-jndi destination will be created. false No
forceJndiDestinations This property in conjunction with the jndidestinations property causes an exception to be thrown if a jndi destination is not found when set to true false No
username The username used when creating a connection   No
password The password used when creating a connection   No
maxRedelivery When a message is rolled back to the destination it was consumed from the JMSRedelivered flag is set on the message. Mule will then reconsume the message and attempt to process it again. This property defines how many times Mule will try processing the message before throwing an exception to be processed by the connectors exception handler (where the message can be logged and/or forwarded to an error queue) 0 No
redeliveryHandler Developers can override the default redelivery behaviour by implementing the interface org.mule.providers.jms.RedeliveryHandler and then setting this property to the fully qualified classname of their handler implementation. org.mule.proivders.jms. DefaultRedeliveryHandler yes
recoverJmsConnections A flag telling Mule if JMS connection recovery should be attempted. The only reason you would want to disable it is to play nicely with some JMS in-container implementations restricting you (e.g. WebSphere Embedded MQ).
@since Mule 1.3
true no

Using Topics, Queues or both

When specifying a destination name and JndiDestinations are not being used the default destination created is a Queue.
For example the Jms endpoint

jms://my.destination

will manifest itself as a Jms Queue called my.destination. To make this a topic you must prepend the destination name with topic:-

jms://topic:my.destination

If you are using a Jms 1.1 compliant server you can use the same JmsConnector for queues and topics. If you are using a Jms 1.0.2b server and you want to use both queues and topics in your Mule configuration, you will need to create 2 JmsConnectors; one with a jndiConnectionfactory that references a QueueConnectionFactory and the other that references a TopicConnectionfactory. Then each Jms endpoint will need to reference the correct connector depending on whether the destination is a topic or a queue. To specify the conector on a jms endpoint you need to add the connector parameter -

jms://my.destination?connector=jmsQueueConnector

or

jms://topic:my.destination?connector=jmsTopicConnector

Specifying Credentials

Client connections may need to supply a username and password when creating a connection. This information can be specified on the URI.

jms://ross:[email protected]?createConnector=ALWAYS

or

jms://ross:secret@topic:my.destination?createConnector=ALWAYS

Note that the 'createConnector' param is set to 'ALWAYS'. This ensures that a new connection is made with the user credentials. When creating JmsConnectors more information is is needed such as ConnectionFactory Jndi details. This can be set as parameters on the URI, but this can get difficult to manage not to mention messy. It is possible to set default properties for connectors when they are created. For more information see this Jms cookBook entry.

See Mule Endpoint URIs for more general information about configuring endpoint URIs.

Jms Selectors

You can set a Jms selector as a filter on an endpoint. The JmsSelectorFilter simply sets the filter expression on the consumer.

<endpoint address="jms://important.queue">
    <filter expression="JMSPriority=9"
        className="org.mule.providers.jms.filters.JmsSelectorFilter">
</endpoint>

Below is the old way of setting a Jms selector on an endpoint, but is still supported for backward compatibility. Also, setting the selector as a URI param can still be useful.

To set it on an explicitly configured endpoint as a property of that endpoint -

<endpoint address="jms://important.queue">
    <properties>
        <property name="selector" value="JMSPriority=9"/>
    </properties>
</endpoint>

Or to specify the same provider using a uri -

jms://important.queue?selector=JMSPriority=9

Durable Subscribers

Durable subscribers can be used by setting the durable property on the JmsConnector, this tells it to make all topic subscribers durable. Only Topic subscriptions can be durable. When a durable subcriptions a durableName is needed by the Jms server to identfy this subscriber. By default, Mule generates a durableName in the following form -

mule.<connector name>.<topic name>

However, if you want to set the durableName yourself, you can do so on the endpoint by setting the durableName property.

<endpoint address="jms://topic:durable.topic">
    <properties>
        <property name="durableName" value="myDurableSubscription"/>
    </properties>
</endpoint>

or the equivilent  -

jms://topic:durable.topic?durableName=myDurableSubscription

You can also specify certain endpoints to be durable while others are not by setting the durable property on the JmsConnector to false and then setting the durable property on the individual endpoints.

<endpoint address="jms://topic:durable.topic">
    <properties>
        <property name="durable" value="true"/>
    </properties>
</endpoint>

or the equivilent  -

jms://topic:durable.topic?durable=true

Overloading Jms behaviour

Some Jms servers require a different sequence of calls when creating Jms resources, for example Oracle's Advanced Queuingrequires that the connection is started before listeners can be registered. In this scenario the user can overload the JmsSupport class to customise the way Jms resources are initialised. Configuring this customisation requires that you tell the JmsConnector to use a custom JmsSupport class.

<connector name=jmsConnector" className="org.mule.providers.jms.JmsConnector">
    <properties>
        <property-factory name="jmsSupport" value="org.foo.jms.CustomJmsSupport"/>
        ...
    </properties>
</connector>

For more information about configuring different Jms Servers go here.
For more information about configuring providers go here.

Jms Transformers

Transformers for the JMS provider can be found at org.mule.providers.jms.transformers

Transformer Description
JMSTransformer This is a base class that provides general JMS message transformation support. If want you can extend this for your own specialised Jms Transfromers but usually the defaults are sufficient.
JMSMessageToObject Will convert a javax.jms.Message or sub-type into an object by extracting the message payload. Users of this transformer can set different return types on the transform to control the way it behaves. \\\\javax.jms.TextMessage - java.lang.String
javax.jms.ObjectMessage - java.lang.Object
javax.jms.BytesMessage - Byte[]. Note that the transformer will check if the payload is compressed and
automatically uncompress the message.
javax.jms.MapMessage - java.util.Map
javax.jms.StreamMessage - java.util.Vector of objects from the Stream Message.
ObjectToJMSMessage Will convert any object to a javax.jms.Message or sub-type into an object. One of the 5 types of JMS message will be created based on the type of Object passed in. \\\\java.lang.String - javax.jms.TextMessage
byte[] - javax.jms.BytesMessage
java.util.Map - javax.jms.MapMessage
java.io.InputStream - javax.jms.StreamMessage
javalang.Object - javax.jms.ObjectMessage

Jms Header Properties

When the message is received and transformed all the message properties are still available via the UMOMessage object. To access sandard Jms properties such as JMSCorrelationID and JMSRedelivered simply use the property name i.e.

String corrId = (String)umoMessage.getProperty("JMSCorrelationID");

boolean redelivered = umoMessage.getBooleanProperty("JMSRedelivered");

any custom header properties on the message can be accessed the same way.

Document generated by Confluence on Nov 27, 2006 10:27